<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>加减计算器</title>
</head>

<body>
    <div id="app">
        <button @click="decrement">-</button>
        <input type="number" v-model="count">
        <button @click="increment">+</button>
    </div>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script type="text/javascript">
        const { createApp } = Vue
        createApp({
            data() {
                return {
                    count: 1,
                }
            },
            methods: {
                increment() {
                    this.count++
                },
                decrement() {
                    if (this.count > 1) {
                        this.count--
                    }
                },
            },
        }).mount('#app')
    </script>
</body>

</html>